% sign = sum of gaussians that is generated randomly but according to minimal distance between
%   INPUT:
%       step - distance between sequential argument values
%       N - number of gaussians to sum
%   OUTPUT:
%       x - argument values
%       sign - signal values
%       means - means argument values of generated gaussians
%       fmeans - means function values of generated gaussians
%       sigmas - mean square deviation array of generated gaussians
function [x signal means fmeans sigmas] = signal8(step, N)

% array of distribution sigmas on [a b]
a = 0.2;
b = 1;
sigmas = a + (b - a) * rand(N,1);
% generating array of distribution means
% using minimal distance between 2 gaussians formula
%
%       distance = alpha * (sigma(i) + sigma(i - 1))
alpha = 4;
means = zeros(1, N);
% 3 - length of standart gaussian template
means(1) = 0;
for i=2:length(means)
    means(i) = means(i - 1) + alpha * (sigmas(i) + sigmas(i - 1));
end;
fmeans = zeros(1, N);
x = min(means) - 3 * max(sigmas):step:max(means) + 3 * max(sigmas);
signal = zeros(1, length(x));
for i=1:N
    signal = signal + rightgaussmf(x, sigmas(i), means(i));
    fmeans(i) = rightgaussmf(means(i), sigmas(i), means(i));
end;